home *** CD-ROM | disk | FTP | other *** search
/ Java Developer's Companion / Java Developer's Companion.iso / Javacup / PR8ADPL7.TAR / productivity_tools / PR8ADPL7 / CryptConnection.java < prev    next >
Encoding:
Java Source  |  1996-05-23  |  1.2 KB  |  65 lines

  1. // CryptConnection.java
  2. // Streams for what will be encrypted communications
  3. import java.io.InputStream;
  4. import java.io.OutputStream;
  5. import java.io.IOException;
  6. import java.io.EOFException;
  7. import LineInputStream;
  8. import LineOutputStream;
  9.  
  10. public class CryptConnection
  11. {
  12.     CryptInputStream in;
  13.     CryptOutputStream out;
  14.  
  15.     CryptConnection(InputStream is, OutputStream os)
  16.     {
  17.     // Should do some setting up of key / etc...
  18.     //
  19.     in = new CryptInputStream(is);
  20.     out = new CryptOutputStream(os);
  21.     }
  22.  
  23.     public CryptInputStream getInputStream()
  24.     {
  25.     return in;
  26.     }
  27.  
  28.     public CryptOutputStream getOutputStream()
  29.     {
  30.     return out;
  31.     }
  32. }
  33.  
  34. // CryptInputStream
  35. // Has the functionality of LineInputStream, plus overrides read to do
  36. // encryption.
  37. class CryptInputStream extends LineInputStream
  38. {
  39.     CryptInputStream(InputStream i)
  40.     {
  41.     super(i);
  42.     }
  43.  
  44.     /* can later do stuff like this :
  45.      * public int read(bytes b[])
  46.      * {
  47.      * in.read(some bytes);
  48.      * decrypt some bytes
  49.      * store plaintext into b[]
  50.      * }
  51.      */
  52. }
  53.  
  54. // CryptOutputStream
  55. // A stream with the functionality of LineOutputStream, plus overloading of
  56. // write() to do encryption.
  57. class CryptOutputStream extends LineOutputStream
  58. {
  59.     CryptOutputStream(OutputStream i)
  60.     {
  61.     super(i);
  62.     }
  63. }
  64.  
  65.